<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

var url="http://www.163.com/new/index.html?token=ashjd2i1nsdh21df2123&name=xietian&age=30";

    function getObject(url){
        url=url.split("?")[1];
        var obj={};
        var arr=url.split("&");
        for(var i=0;i<arr.length;i++){
            var arr1=arr[i].split("=");
            obj[arr1[0]]=isNaN(arr1[1]) ? arr1[1] : Number(arr1[1]);
        }
        return obj;
    }

// 另一种写法:
    function getObject(url){
       return url.split("?")[1].split("&").reduce(function(value,item){
          var arr=item.split("=");
          value[arr[0]]=isNaN(arr[1]) ? arr[1] : Number(arr[1]);
          return value;
       },{});
    }

    var o=getObject(url);
    console.log(o);











    </script>
</body>
</html>